package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	CheckResultEventNew          = "mes.CheckResultNew"
	CheckResultEventBeforeCreate = "mes.CheckResultBeforeCreate"
	CheckResultEventBeforeUpdate = "mes.CheckResultBeforeUpdate"
	CheckResultEventBeforeSave   = "mes.CheckResultBeforeCreate mes.CheckResultBeforeUpdate"
	CheckResultEventAfterCreate  = "mes.CheckResultAfterCreate"
	CheckResultEventAfterUpdate  = "mes.CheckResultAfterUpdate"
	CheckResultEventAfterSave    = "mes.CheckResultAfterCreate mes.CheckResultAfterUpdate"
	CheckResultEventDelete       = "mes.CheckResultDelete"

	CheckResultAccessControlEvent = "mes.CheckResultAccessControl"
)

func GetCheckResultConfig() *mgo.DocConfig {
	return CheckResult_Config
}

var CheckResult_Config *mgo.DocConfig

func init() {
	CheckResult_Config = NewCheckResultConfig()
}

func NewCheckResultConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.CheckResult",
		Fields: []string{
			"check", "tag", "num", "group",
		},
		RelationFields: []string{
			"check", "tag", "group",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"check": {
				Config:     GetCheckConfig,
				DocName:    "Check",
				JoinType:   "O",
				KeyInside:  "checkId",
				KeyOutSide: "id",
			},

			"tag": {
				Config:     GetCheckTagConfig,
				DocName:    "CheckTag",
				JoinType:   "O",
				KeyInside:  "tagId",
				KeyOutSide: "id",
			},

			"group": {
				Config:     GetCheckResultGroupConfig,
				DocName:    "CheckResultGroup",
				JoinType:   "O",
				KeyInside:  "groupId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
